﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CompilerForC.LexicalAnalysis
{
    /// <summary>
    /// Enumerates error codes of errors that can be reported by the Lexer.
    /// </summary>
    public enum LexerErrorCode
    {
        None,
        InvalidSeparation,
        UnexpectedSymbol
    }

    /// <summary>
    /// Encapsulates single tokenization error.
    /// </summary>
    public class LexerError
    {
        #region Private Fields
        
        private LexerErrorCode _code = LexerErrorCode.None;
        private int _lineNumber = -1;
        private string _description = string.Empty;

        #endregion Private Fields

        #region Public Properties

        /// <summary>
        /// Gets or sets error code.
        /// </summary>
        public LexerErrorCode Code
        {
            get { return _code; }
            set { _code = value; }
        }

        /// <summary>
        /// Gets or sets source line where the error occurred.
        /// </summary>
        public int LineNumber
        {
            get { return _lineNumber; }
            set { _lineNumber = value; }
        }
        
        /// <summary>
        /// Gets or sets description of the error.
        /// </summary>
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        #endregion Public Properties

        #region Constructors

        /// <summary>
        /// Constructs uninitialized lexer error.
        /// </summary>
        public LexerError()
        {
        }

        /// <summary>
        /// Constructs and initializes lexer error.
        /// </summary>
        /// <param name="code">Error code.</param>
        /// <param name="lineNumber">Source line where the error occurred</param>
        /// <param name="description">Description of the error.</param>
        public LexerError(LexerErrorCode code, int lineNumber, string description)
        {
            _code = code;
            _lineNumber = lineNumber;
            _description = description;
        }

        #endregion Constructors
    }
}
